#include "Lexical.h"
#include "Grammatical.h"

int main() {
	lexical Lexical;
	grammatical Grammatical;
	Lexical.initLexical();
	Grammatical.initGrammatical();
	std::vector<std::string>context;
	for (int i = 1; i <= 1; i++) {
//		std::string path1 = "testfile" + std::to_string(i) + std::string(".txt");
//		std::string path2 = "output" + std::to_string(i) + std::string(".txt");
		std::string path1 = "testfile15.txt";
		std::string path2 = "output15.txt";
		context.clear();
		std::ifstream in;
		in.open(path1, std::ios::in);
		while (!in.eof()) {
			std::string str;
			getline(in, str);
			context.push_back(str);
		}
		in.close();
		
		auto words = Lexical.analysis(context);
		
		auto result = Grammatical.analysis(words);

		std::ofstream out;
		out.open(path2, std::ios::out);
		for (auto p : result) {
			if (p.second != "") out << p.first << ' ' << p.second << '\n';
			else out << '<' << p.first << '>' << '\n';
		}
		out.close();
	}
}